<?php

namespace api\modules\mall\controllers;

use api\extensions\ApiBaseController;
use api\services\mall\MallSpecialService;

/**
 * 专题
 */
class SpecialController extends ApiBaseController
{

    /**
     * 专题内容
     * * */
    public function actionContent()
    {

        $params = \Yii::$app->request->post();
        $rules = [
            [['code'], 'default', 'value' => '', 'message' => '默认首页'],
        ];
        $validate = $this->validateParams($params, $rules);
        if ($validate) {
            return $this->jsonError($validate);
        }

        return MallSpecialService::getSpecial($this->params['code'], false);
    }

    /**
     * 专题商品信息
     * * */
    public function actionGoods()
    {
        $params = \Yii::$app->request->post();
        $rules = [
            [['special_floor_id', 'page'], 'required', 'message' => '{attribute}属必填项'],
        ];
        $validate = $this->validateParams($params, $rules);
        if ($validate) {
            return $this->jsonError($validate);
        }

        return MallSpecialService::getSpecialFloorGoods($this->params['special_floor_id'], $this->params['page']);
    }
}
